//
//  AppDelegate.swift
//  AIPhotoProcess
//
//  Created by aw031 on 17/10/2025.
//

import UIKit
import IQKeyboardManagerSwift



@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    enum RootViewControllerType {
        case home
        case lanuch
    }
    var window: UIWindow?
//    var isHotStart : Bool = false
//    var storeVersion : String = ""
    
    
    lazy var lanuchVC = LanuchViewController()
    
    lazy var homeNavigationController: BaseNavigationController = {
        
        let homeVC = HomeViewController()
        let navi =  BaseNavigationController(rootViewController: homeVC)
        return navi
    }()
    
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        
        window = UIWindow.init(frame:KScreenBounds )
        window?.backgroundColor = UIColor.white;
        
        if #available(iOS 15.0, *) {
            UITableView.appearance().sectionHeaderTopPadding = 0
        }
        configIQKeyboard()
        changeRootViewControllerWithRootVCType(.home)
        window?.makeKeyAndVisible()
        return true
    }


    //MARK: -- 配置IQKeyboard
    func configIQKeyboard() {
        //全局键盘设置
        IQKeyboardManager.shared.isEnabled = true
        //键盘弹出时，点击背景，键盘收回
        IQKeyboardManager.shared.resignOnTouchOutside = true
        //隐藏键盘上面的toolBar,默认是开启的
        // IQKeyboardManager.shared.enableAutoToolbar = false;
    }
    
    //MARK: -- 更换 根视图控制器
    func changeRootViewControllerWithRootVCType(_ rootVCType : AppDelegate.RootViewControllerType , subPage:String = "") {
        
        switch rootVCType {
        case .lanuch:
            window?.rootViewController = lanuchVC
        case .home:
//            isHotStart = true
            window?.rootViewController = homeNavigationController
            
        }
    }
    
    
    
}

